/**
 *
 */
/*<!-- 页面数据量切换脚本 -->*/
function changePageSize(size){
	$.ajax({
		type:"post",
		url:"book/changePageSize.do",
		datatype: "json",
		async:true,
		data:{
			"pageSize":size,
		},
		success:function(result) {
			SelectPage(1);
		},
		error:function(){
			AjaxError();
		}
	});
}
//输入不能为空
function InputNotNull(value,str){
	if(value.val().length == 0){
		ErrorTipBottomCenter(str);
        return false;
	}else{ 
		return true;
	}
}

//邮箱隐藏
function HideEmail(email){
	if (String (email).indexOf ('@') > 0) {
        let newEmail, str = email.split('@'), _s = '';

        if (str[0].length > 4) {
            _s = str[0].substr (0, 4);
            for (let i = 0; i < str[0].length - 4; i++) {
                _s += '*';
            }
        } else {
            _s = str[0].substr (0, 1);
            for (let i = 0; i < str[0].length - 1; i++) {
                _s += '*';
            }
        }
        newEmail = _s + '@' + str[1];
        return newEmail;
    } else {
        return email;
    }
}
//验证码倒计时
function settime(obj,input) {
	if (countdown == 0) {
		input.attr('disabled',false);
		obj.attr('disabled', false);
		obj.html("免费获取验证码")
		countdown = 60;
		return;
	} else {
		input.attr('disabled',true);
		obj.attr('disabled', true);
		obj.html("重新发送("+countdown+")");
		countdown--;
	}
	setTimeout(function () {settime(obj,input)}, 1000)
}

//手机号隐藏
function HidePhone(phone){
	let newPhone = '';
　　if (phone.length > 7) {
		newPhone=phone.substr(0, 3) + '****' + phone.substr(7);
        return newPhone;
    } else {
        return phone;
    }
}


//检测用户是否访问受限
function UserLimitedAccess(limitedAccess){
	var str;
	if(limitedAccess==1){//权限不足
		str="用户权限不足，无法访问";
	}
	if(limitedAccess.length != 0){
		swal({
				title: "权限不足",
				text: str,
				type: "warning",
				confirmButtonText: "关闭",
				closeOnConfirm: false
			},
			function(){
				window.location.replace("/app/main");
			});
	}
}
//检测用户是否在其他地方登陆
function UserLineOut(LineOut){
	var str;
	if(LineOut==1){
		str="你已经在其他客户端登陆，如果非本人操作，请更改密码";
	}
	if(LineOut.length != 0){
		swal({
				title: "强制离线",
				text: str,
				type: "error",
				confirmButtonText: "关闭",
				closeOnConfirm: false
			},
			function(){
				window.location.replace("/app/");
			});
	}
}
//页面加载完毕
$(function (){
	var limitedAccess = $('#limitedAccess').val();
	var LineOut = $('#LineOut').val();
	//检查用户权限
	UserLimitedAccess(limitedAccess);
	//检查是否其他客户端登陆
/*	setTimeout(function() {
		if(LineOut.length!=0){
			alert(LineOut)
			UserLineOut(LineOut);
			//window.location.reload();
		}
	},5000);*/
})